/**   
 * @Title: CaifutongTokenIDCommunicater 
 * @Package com.esun.rabbit2.communicaters.recharg 
 * @Description: (获取财付通单号接口)
 * @author: Kuroky Chengxt@500wan.com
 * @date: 2012-02-07 下午2:06:12
 * Copyright: (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.recharg;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import android.content.pm.PackageManager.NameNotFoundException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.DistributionChannels;
import com.esun.config.Key;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;

/**
 * @ClassName: CaifutongTokenIDCommunicater
 * @Description: (获取财付通单号接口)
 * @author: Kuroky Chengxt@500wan.com
 * @date: 2012-02-07 下午2:06:12
 * 
 */
public class CaifutongTokenIDCommunicater extends ServerCommunicater {

	private String msgServer = Config.NULLMARK;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String str) {
		this.msgServer = str;
	}
	
	// 财付通交易初始化，获取交易id
	public boolean isGetOrderIDSucceed(String version, String money) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException,
			NameNotFoundException {
		boolean isSucceed = false;

		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();

		list.add(mapItem(Config.PASER_MID, BussinessCode.MID_CAIGUTONG_GET_TOKEN_ID));
		list.add(mapItem(Config.PASER_CK, UserInfo.getUserInfo().getUserSession()));
		list.add(mapItem(Key.KEY_USERNAME, UserInfo.getUserInfo().getUserName()));
		list.add(mapItem(Key.KEY_PASSWORD, UserInfo.getUserInfo().getUserPwd()));
		list.add(mapItem(Key.KEY_VERSION, version));
		list.add(mapItem(Key.KEY_CHANNEL, DistributionChannels.QUDAO));
		list.add(mapItem(Key.KEY_MONEY, money));

		super.getServerResponse(list, true);
		setMsgServer(super.getServerMsg());
		if (super.getState() == 100) {
			isSucceed = true;
		}

		return isSucceed;
	}

	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
